﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using xraiding.Models;

namespace xraiding.ViewModels
{
    public class AvailableTimeSlotViewModel
    {
        private XRaidingEntities _entities;
        public List<SelectListItem> Days { get; set; }
        public int Index { get; set; }
        public List<SelectListItem> Hours { get; set; }
        [Display(Name = "Select Day")]
        public int SelectedDay { get; set; }
        [Display(Name="Start Time")]
        public int SelectedStartTime { get; set; }
        [Display(Name = "End Time")]
        public int SelectedEndTime { get; set; }

        public AvailableTimeSlotViewModel(int index)
        {
            Index = index;            
        }

        public AvailableTimeSlotViewModel()
        {
            
        }

        public void LoadDataFromDB()
        {
            _entities = XRaidingRepository.GetXRaidingConnection();
            Days = new List<SelectListItem>();
            _entities.Days.ToList().ForEach(d => Days.Add(new SelectListItem { Value = d.DayId.ToString(), Text = d.Name }));
            Hours = new List<SelectListItem>();
            _entities.Hours.ToList().ForEach(h => Hours.Add(new SelectListItem { Value = h.HourId.ToString(), Text = h.Name }));
        }              
    }
}